package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.pojo.WiringInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WiringInfoMapper {

    // 批量插入数据
    @Insert("<script>" +
            "INSERT INTO wiring_info (parent_company, company, user_code, property_code, point_code, user_name, maintain_team, substation, wiring, court, court_code, voltage_level, pt_value, user_label, over_type, score, norm_over_up_index, over_up_up_index, severe_over_up_index, norm_over_down_index, over_down_down_index, severe_over_down_index, norm_over_up_time, over_up_up_time, severe_over_up_time, norm_over_down_time, over_down_down_time, severe_over_down_time, total_time, electric_max_value, max_value_time, electric_min_value, min_value_time, electricity_type, is_duplicate_power, is_photovoltaic_user, electric_meter_code, contract_capacity, operating_capacity) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.parentCompany}, #{item.company}, #{item.userCode}, #{item.propertyCode}, #{item.pointCode}, #{item.userName}, #{item.maintainTeam}, #{item.substation}, #{item.wiring}, #{item.court}, #{item.courtCode}, #{item.voltageLevel}, #{item.ptValue}, #{item.userLabel}, #{item.overType}, #{item.score}, #{item.normOverUpIndex}, #{item.overUpUpIndex}, #{item.severeOverUpIndex}, #{item.normOverDownIndex}, #{item.overDownDownIndex}, #{item.severeOverDownIndex}, #{item.normOverUpTime}, #{item.overUpUpTime}, #{item.severeOverUpTime}, #{item.normOverDownTime}, #{item.overDownDownTime}, #{item.severeOverDownTime}, #{item.totalTime}, #{item.electricMaxValue}, #{item.maxValueTime}, #{item.electricMinValue}, #{item.minValueTime}, #{item.electricityType}, #{item.isDuplicatePower}, #{item.isPhotovoltaicUser}, #{item.electricMeterCode}, #{item.contractCapacity}, #{item.operatingCapacity})" +
            "</foreach>" +
            "</script>")
    void batchInsert(List<WiringInfo> list);

    //根据所属变电站查找
    @Select("select * from wiring_info where Substation=#{Substation}")
    IPage<WiringInfo> findBySubstation(String Substation,Page<WiringInfo> page);

    //根据维护班组查找
    @Select("select * from wiring_info where MaintainTeam=#{MaintainTeam}")
    IPage<WiringInfo> findByMaintainTeam(String MaintainTeam,Page<WiringInfo> page);

    //根据所属配变台区查找
    @Select("select * from wiring_info where Court=#{Court}")
    IPage<WiringInfo> findByCourt(String Court,Page<WiringInfo> page);

    //根据是否光伏用户查找
    @Select("select * from wiring_info where IsPhotovoltaicUser=#{IsPhotovoltaicUser}")
    IPage<WiringInfo> findByIsPhotovoltaicUser(String IsPhotovoltaicUser,Page<WiringInfo> page);

    // 查询所有数据（示例）
    @Select("SELECT * FROM wiring_info")
    IPage<WiringInfo> getAllWiringInfo(Page<WiringInfo> page);
}

